package com.tencent.wxcloudrun.util;

import java.util.*;

/**
 * @Author ZhaoZiYin
 * @Date 2025/5/7
 * @Description 数字工具类
 */
public class NumberUtils {

    /**
     * @Author: ZhaoZiYin
     * @Date: 2025/5/7
     * @Params: [min, max, count]
     * @Return: List<Integer>
     * @Description: 获取随机数组
     */
    public static List<Integer> getRandomNumber(int min, int max, int count) {
        if (max < min || max - min < count) {
            return null;
        }
        Random random = new Random();
        Set<Integer> numbers = new HashSet<>(count);

        while (numbers.size() < count) {
            int randomNumber = random.nextInt(max - min) + min;
            numbers.add(randomNumber);
        }

        // 如果需要按顺序存储，可以转换为 List
        return new ArrayList<>(numbers);
    }

}
